package com.example.demo.result;

public class ResultUtil {
    /**
     * 成功且带数据
     **/
    public static Result success(Object object) {
        Result result = new Result();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(object);
        return result;
    }
    public static Result getMsgSuccess(Integer count , Object object){
        Result result = new Result();
        result.setCount(count);
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(object);
        return result;
    }
    /*
    * 成功且自定义提示信息且不带数据
    * */


    /**
     * 成功但不带数据
     **/
    public static Result success() {

        return success(null);
    }

    /**
     * 失败自定义返回信息
     **/
    public static Result error(String msg) {
        Result result = new Result();
        result.setCode(ResultEnum.ERROR.getCode());
        result.setMsg(msg);
        return result;
    }
    /*
    * 失败无自定义信息
    * */

    public static Result error(){
        Result result = new Result();
        result.setCode(ResultEnum.ERROR.getCode());
        result.setMsg(ResultEnum.ERROR.getMsg());
        return result;
    }
    public static Result exists(){
        Result result = new Result();
        result.setCode(ResultEnum.EXISTS.getCode());
        result.setMsg(ResultEnum.EXISTS.getMsg());
        return result;
    }
}
